class Captcha {
    /**
     * 发送手机号验证码
     * @param phone 手机号
     * @return {Promise<string>} 发送成功返回json格式的数据
     */
    sendPhoneCaptcha(phone){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/phone/captcha",
                method: "GET",
                data: {
                    phone: phone,
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 发送邮箱验证码
     * @param mailbox 邮箱
     * @return {Promise<unknown>} 200 发送成功 其他则发送失败
     */
    sendMailboxCaptcha(mailbox){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/mailbox/captcha",
                method: "GET",
                data: {
                    mailbox: mailbox,
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 验证邮箱验证码
     * @param mailbox 邮箱
     * @param code 验证码
     * @return {Promise<unknown>} 200验证码正确 其他则错误或报错
     */
    verifyMailboxCaptcha(mailbox,code){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/verify/mailbox/captcha",
                method: "GET",
                data: {
                    mailbox: mailbox,
                    code:code
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }
}